from odoo import api, fields, models, _


class Advance_paid(models.Model):
    _name = 'check.advance'
    _description = "预付房费"

    # 房间信息

    house_id = fields.Many2one(
        'check.house',
        '当前房号',
    )

    # 房间状态
    stage = fields.Boolean(
        '房间状态',
        related='house_id.Stage',
    )

    # 主客
    guest_id = fields.Many2one(
        related='house_id.guest_id',
        string='主客姓名'
    )

    # 押金总额
    Money = fields.Monetary(
        "押金总额",
        'currency_id',
        related='guest_id.Money'
    )

    # 已结总额
    end_Money = fields.Monetary(
        '已结总额',
        'currency_id',
    )

    way = fields.Selection(
        [
            ('0', '支付宝')
        ]
        , default="0", string="收款方式"
    )

    # 入住单价
    unit_price = fields.Monetary(
        "入住单价",
        'currency_id',
        related='house_id.pre_price'
    )

    # 预离时间
    leave_date = fields.Date(
        '预离时间',
        related='guest_id.leave_day'
    )

    total_consume = fields.Monetary(
        "消费总额",
        'currency_id',
        related='guest_id.Total_consume'
    )

    advance_paid = fields.Monetary(
        '本次预付房费',
        'currency_id',
    )

    # price helper
    currency_id = fields.Many2one('res.currency',
                                  default=lambda self: self.env.user.company_id.currency_id, )


    note = fields.Char('备注信息')


